<!-- 单纯的提示一下 -->
<template>
  <div>
    <div class="sim_view" v-if="index == 0">
      <el-dialog
        title
        :visible.sync="dialogVisible"
        lock-scroll
        width="500px"
        :show-close="false"
        :modal="false"
        :close-on-click-modal="false"
      >
        <div slot="title"></div>
        <div class="dialog_div">
          <div class="dialog_content">
            <div class="header_view">
              <i class="el-icon-close" @click="hide"></i>
            </div>
            <i class="el-icon-success"></i>
            <div style="font-size: 12px;margin-top: 6px;">{{ dialogData.text }}</div>
          </div>
        </div>
      </el-dialog>
    </div>
    <div class="hc_view" v-else-if="index == 1">
      <el-dialog
        title="操作确认"
        :visible.sync="dialogVisible"
        lock-scroll
        width="400px"
        :close-on-click-modal="true"
        :before-close="handleClose"
      >
        <div class="dialog_div_1">
          <i :class="dialogData.classIcon" v-if="dialogData.classIcon != null"></i>
          <div style="font-size: 14px;margin-left: 16px;" v-html="dialogData.text"></div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button
            @click="cancel()"
            size="small"
            v-if="dialogData.cancelVisible"
          >{{dialogData.cancelText}}</el-button>
          <el-button type="primary" @click="sure()" size="small">{{dialogData.sureText}}</el-button>
        </span>
      </el-dialog>
    </div>
    <el-dialog
        title="操作确认"
        :visible.sync="freightVisible"
        lock-scroll
        width="400px"
        :close-on-click-modal="true"
      >
        <div style="width: 100%;text-align: center">
          <span>本单已付物流运费，请输入账户付款信息</span>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="freightVisible = false" size="small">确定</el-button>
        </span>
      </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    tipsData: Object,
    // paddingClass: {
    //   type: Boolean,
    //   default: false,
    // },
  },
  data () {
    return {
      dialogVisible: false,
      index: 0,
      dialogData: {
        text: '',
        classIcon: 'el-icon-warning',
        sureText: '确 定',
        cancelText: '取 消',
        cancelVisible: true,
        dataLoading: false, // 数据请求状态
      },
      freightVisible: false, //运费已付提示
    }
  },
  methods: {
    // 用户点击空白或者使用关闭按钮关闭弹窗执行该方法
    handleClose (done) {
      done() // 调用该方法完成后续操作
      this.$emit('onCancel')
    },
    onConfirm () {
      this.dialogVisible = !this.dialogVisible
      this.$emit('onConfirm', this.tipsData.tipsMark)
    },
    showFreight () {
      this.freightVisible = true
    },
    show (data) {
      Object.assign(this.$data.dialogData, this.$options.data().dialogData)
      this.dialogData.text = data.text
      this.index = data.index
      this.dialogVisible = true
      if (data.index == 0) {
        let that = this
        setTimeout(() => {
          this.hide()
        }, 1000);
      }
    },
    // 显示一个按钮，可以修改图标
    showOneBtn (classIcon, text, sureText) {
      Object.assign(this.$data.dialogData, this.$options.data().dialogData)
      this.dialogData.classIcon = classIcon
      this.dialogData.text = text
      this.dialogData.sureText = sureText
      this.dialogData.cancelVisible = false
      this.index = 1
      this.dialogVisible = true
    },
    // 显示两个按钮，可以修改图标
    showTwoBtn (classIcon, text, sureText, cancelText) {
      Object.assign(this.$data.dialogData, this.$options.data().dialogData)
      this.dialogData.classIcon = classIcon
      this.dialogData.text = text
      this.dialogData.sureText = sureText
      this.dialogData.cancelText = cancelText
      this.index = 1
      this.dialogVisible = true
    },
    hide () {
      this.dialogVisible = false
    },
    sure () {
      if (this.dialogData.dataLoading) {
        return
      }
      this.dialogData.dataLoading = true
      this.hide()
      this.$emit('onSure')
    },
    cancel () {
      if (this.dialogData.dataLoading) {
        return
      }
      this.dialogData.dataLoading = true
      this.hide()
      this.$emit('onCancel')
    },
  },
}
</script>

<style lang="scss" scoped>
.sim_view {
  ::v-deep .el-dialog {
    margin-top: 33vh !important;
    overflow: hidden;
    background: transparent;
    box-shadow: none;
    -webkit-box-shadow: none;
    .el-dialog__body {
      padding: 0;
    }
    .el-dialog__header {
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: transparent solid 1px;
      span {
        font-size: 0.300019rem;
        color: #666;
        font-weight: 600;
      }
      .el-dialog__headerbtn {
        position: static;
        .el-icon-close {
          color: #999;
          font-size: 0.48753rem;
        }
      }
    }
  }
}
.hc_view {
  ::v-deep .el-dialog {
    margin-top: 33vh !important;
    overflow: hidden;
    // background: transparent;
    box-shadow: none;
    -webkit-box-shadow: none;
    .el-dialog__body {
      padding: 0;
    }
    .el-dialog__header {
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: transparent solid 1px;
      span {
        font-size: 0.300019rem;
        color: #666;
        font-weight: 600;
      }
      .el-dialog__headerbtn {
        position: static;
        .el-icon-close {
          color: #999;
          font-size: 0.48753rem;
        }
      }
    }
  }
}

.dialog_div {
  width: 100%;
  display: flex;
  justify-content: center;
  background-color: transparent;

  .dialog_content {
    width: 120px;
    height: 70px;
    background: rgba(229, 246, 255, 1);
    border: 1px solid #91d5fe;
    opacity: 1;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    .header_view {
      width: 100%;
      display: flex;
      justify-content: flex-end;
      background: transparent;
      padding: 5px 5px 0 0;
      i {
        font-size: 15px;
        color: #666;
      }
    }

    i {
      font-size: 15px;
      color: #1890fc;
    }
  }
}
.dialog_div_1 {
  display: flex;
  height: 100px;
  justify-content: center;
  align-items: center;
  .el-icon-warning {
    color: #fd5050;
    font-size: 43px;
  }
  .el-icon-success {
    color: #52c41a;
    font-size: 43px;
  }
}
// .dialog_div_1_padding{
//   margin: 30px 52px;
// }
.dialog-footer {
  display: flex;
  justify-content: center;
}
</style>